package Test1;


import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.WindowConstants;

public class VoxLayoutExp extends JFrame {
    
	private boolean DEBUG = false;
	JPanel panel = new JPanel();
	
    public VoxLayoutExp() {
        
        setTitle("Box Layout Example");
        setSize(600, 650);
        getContentPane().setLayout(
                new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
        
        JButton btn1 = new JButton("Button 1");
        JButton btn2 = new JButton("Button 2");
        JButton btn3 = new JButton("Button 3");
        
        JButton btn4 = new JButton("Button 4");
        getContentPane().add(btn1);
        getContentPane().add(btn2);
        btn1.setAlignmentX(Component.CENTER_ALIGNMENT);
        getContentPane().add(btn3);
        getContentPane().add(btn4);
    
    
String [] columnNames = {"Class Code, Class Description, Season Code", "Season Discription"};
		
		Object [][] data = {{"MT", "Math", "SP2013", "SPRING 2013"},{ "RD", "Reading", "FA2013", "Fall 2013"}};
		
		 final JTable table = new JTable(data, columnNames);
	        table.setPreferredScrollableViewportSize(new Dimension(500, 70));
	        table.setBounds(25, 190, 185, 120);
	        table.setEnabled(false);
	        table.setFillsViewportHeight(true);

	        if (DEBUG) {
	            table.addMouseListener(new MouseAdapter() {
	                public void mouseClicked(MouseEvent e) {
	                    printDebugData(table);
	                }
	            });
	        }

	        //Create the scroll pane and add the table to it.
	        JScrollPane scrollPane = new JScrollPane(table);

	        //Add the scroll pane to this panel.
	        add(scrollPane);
	        
	        panel.add(table);
    
    
	        getContentPane().add(panel);
    
    
    }
    
    private void printDebugData(JTable table) {
        int numRows = table.getRowCount();
        int numCols = table.getColumnCount();
        javax.swing.table.TableModel model = table.getModel();

        System.out.println("Value of data: ");
        for (int i=0; i < numRows; i++) {
            System.out.print("    row " + i + ":");
            for (int j=0; j < numCols; j++) {
                System.out.print("  " + model.getValueAt(i, j));
            }
            System.out.println();
        }
        System.out.println("--------------------------");
    	}

    public static void main(String[] args) {
        
        VoxLayoutExp ble = new VoxLayoutExp();
        ble.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        ble.setVisible(true);
        
    }
}   
  